const { defineConfig } = require("@vue/cli-service");
const webpack = require("webpack");
const CopywebpackPlugin = require("copy-webpack-plugin");
const path = require("path");
function resolve(dir) {
	return path.join(__dirname, dir);
}
module.exports = defineConfig({
	transpileDependencies: true,
	configureWebpack: {
		resolve: {
			alias: {
				"@": resolve("src"),
				"@public": resolve("public"),
				"@/components/Cesium": resolve("src/components/Cesium"),
			},
		},
		module: {
			rules: [
				{
					test: /cesium\.worke/g,
					use: [
						{
							loader: "babel-loader",
							options: {
								presets: ["@babel/preset-env"],
							},
						},
						{
							loader: "worker-loader",
							options: {
								worker: "SharedWorker",
							},
						},
					],
				},
			],
		},
		plugins: [
			new CopywebpackPlugin({
				patterns: [
					{ from: "node_modules/cesium/Build/Cesium/Workers", to: "Workers" },
					{ from: "node_modules/cesium/Source/Assets", to: "Assets" },
					{ from: "node_modules/cesium/Source/Widgets", to: "Widgets" },
				],
			}),
			new webpack.DefinePlugin({
				CESIUM_BASE_URL: JSON.stringify(""),
			}),
		],
	},
});
